import {
    center,
    grid,
    header,
    button,
    search,
} from '@/css/VueCss.module.scss' ;

export default {
    title: '最新客户',
    order: 1,
    items: [{
        region: 'center',
        class: center,
        layout: 'vertical',
        items: [{
            items: [{
                id: 'search',
                class: search,
                widget: 'search-datesearch',
                times: [{
                    label: '今日',
                    value: 'today'
                }, {
                    label: '昨日',
                    value: 'yesterday'
                },{
                    label: '近7日',
                    value: 'lately7'
                },{
                    label: '近30日',
                    value: 'lately30'
                }],
                rangeTimes: true,
                selects: [{
                    field: 'source_uuid',
                    placeholder: '请选择客户来源',
                    dictionary: {
                        path: 'common/dictionary/config',
                        params: {
                            name: 'crm_customer_source'
                        },
                    }
                },{
                    field: 'industry_uuid',
                    placeholder: '选择所属行业',
                    dictionary: {
                        path: 'common/dictionary/config',
                        params: {
                            name: 'crm_customer_industry',
                        },
                    }
                }],
                text:{
                    field: 'keywords',
                    placeholder: '请输入客户(公司)'
                },
                onSearch: [{
                    action:'grid-load',
                    target:'$widgets.grid',
                    params: {
                        status_uuid: 0,
                        page_size: '$widgets.grid.pageSize',
                        keywords: '$params.keywords',
                        source_uuid: '$params.source_uuid',
                        industry_uuid: '$params.industry_uuid',
                    }
                }]
            }, {
                class: header,
                layout: 'horizontal',
                items: [{
                    class: button,
                    widget: 'button',
                    value: '新增',
                    onClick: [{
                        action:'dialog-show',
                        path:'PotentialCustomers/LatestCustomer/Edit',
                        params: {
                            title:"'新增客户'",
                            form: {
                                status_uuid:0,
                            }
                        },
                        applyActions: [{
                            action: 'call',
                            target: '$widgets.grid',
                            method: 'reload'
                        }],
                        cancelActions:[{
                            action:'print',
                            description:'取消对话框'
                        }]
                    }]
                }, {
                    class: button,
                    widget: 'button',
                    value: '删除',
                    onClick:[{
                        action:'confirm',
                        title:'删除数据',
                        message:'是否删除勾选数据?',
                        confirm:[{
                            var:'checkedItemIds',
                            action:'array-value',
                            target:'$widgets.grid.checkedItems',
                            key:'id'
                        },{
                            action:'print',
                            description:'列表勾选项',
                            value:'$vars.checkedItemIds'
                        },{
                            action:'service',
                            path:'crm/customer/allremove',
                            params:{
                                id:'$vars.checkedItemIds'
                            }
                        },{
                            action: 'call',
                            target: '$widgets.grid',
                            method: 'reload'
                        }]
                    }]
                // },{
                //     class: button,
                //     widget: 'basic-groupbutton',
                //     value: '删除',
                //     onClick: [{
                //         action: 'dialog-show',
                //         path: 'grid/item/detail/Drawer',
                //         params: {
                //             value: '`第 ${$view.count ++} 次点击`'
                //         }
                //     }]
                },{
                    class: button,
                    type: 'primary',
                    widget: 'button',
                    value: '转为正式客户',
                    onClick: [{
                        action:'dialog-show',
                        path:'PotentialCustomers/LatestCustomer/StateEdit',
                        params: {
                            title:"'转为正式客户'",
                            form: {
                                id:'$widgets.grid.selectedItem.id',
                            }
                        },
                        applyActions: [{
                            action: 'call',
                            target: '$widgets.grid',
                            method: 'reload'
                        }],
                        cancelActions: [{
                            action: 'print',
                            description: '取消对话框'
                        }]
                    }]
                }]
            }]
        },{
            id:'grid',
            class: grid,
            widget:'grid',
            service: {
                path: 'crm/customer/list',
                params: {
                    status_uuid: 0,
                }
            },
            pageSize:20,
            columns:[{
                prop:'name',
                label:'客户名称(公司)',
                minWidth: 220
            },{
                prop:'category_uuid',
                label:'客户分类',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_customer_category',
                    },
                },
                width: 150
            },{
                prop:'industry_uuid',
                label:'所属行业',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_customer_industry',
                    },
                },
                width: 150
            },{
                prop:'source_uuid',
                label:'客户来源',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_customer_source',
                    },
                },
                width: 120
            }, {
                prop:'level_uuid',
                label:'客户等级',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_customer_level',
                    },
                },
                width: 120
            },{
                prop:'stage_uuid',
                label:'当前阶段',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_sale_stage',
                    },
                },
                width: 120
            }, {
                prop: 'label_uuid',
                label: '客户标签',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'crm_customer_label',
                    },
                },
                width: 120
            },{
                prop:'salesman',
                label:'销售联系人',
                width: 150
            },{
                prop:'contact',
                label:'客户联系人',
                width: 150
            },{
                prop:'phone',
                label:'手机号码',
                width: 150
            },{
                prop:'last_follow_time',
                label:'最近联系',
                width: 180
            },{
                prop:'next_plan_time',
                label:'下次跟进',
                width: 180
            }],
            buttons:[{
                value:'编辑',
                onClick:[{
                    action:'dialog-show',
                    path:'PotentialCustomers/LatestCustomer/Edit',
                    params: {
                        form:'$params',
                        title:"'编辑客户信息'"
                    },
                    applyActions: [{
                        action: 'call',
                        target: '$widgets.grid',
                        method: 'reload'
                    }],
                    cancelActions:[{
                        action:'print',
                        description:'取消对话框'
                    }]
                }]
            },{
                value:'详情',
                onClick:[{
                    action:'dialog-show',
                    path:'PotentialCustomers/LatestCustomer/Details',
                    params: '$params',
                }]
            },{
                value:'删除',
                type:'danger',
                onClick:[{
                    action:'confirm',
                    title:'删除数据',
                    message:'是否删除该条数据?',
                    confirm:[{
                        action:'service',
                        path:'crm/customer/remove',
                        params: {
                            id:'$params.id'
                        }
                    },{
                        action:'call',
                        target:'$widget',
                        method:'reload'
                    }]
                }]
            },{
                value:'新增回访',
                onClick:[{
                    action:'dialog-show',
                    path:'PotentialCustomers/LatestCustomer/FollowUp',
                    params: {
                        form:'$params',
                        title:"'新增回访'"
                    },
                    applyActions: [{
                        action: 'call',
                        target: '$widgets.grid',
                        method: 'reload'
                    }],
                    cancelActions:[{
                        action:'print',
                        description:'取消对话框'
                    }]
                }]
            }],
            flex:true,
            operationWidth: 105,
            enableCheckboxColumn:true,
        }]
    }]
} ;
